package com.manlost.web.common.cookie;

import org.apache.commons.lang.StringUtils;

/**
 * cookieKey
 * 
 * @author kang.zhouk
 *
 */
public enum MLostCookieKeyEnum {
	/**
	 * 用户名
	 */
	@MLostCookieKeyPolicy(withinNames = { MLostCookieNameEnum.MLSC_TEMP, MLostCookieNameEnum.MLSC_FOREVER})
	ACCOUNT_NAME("name"),
    
    /**
     * 用户email
     */
    @MLostCookieKeyPolicy(withinNames = { MLostCookieNameEnum.MLSC_TEMP, MLostCookieNameEnum.MLSC_FOREVER})
	ACCOUNT_EMAIL("email"),
    
    /**
     * 用户状态
     */
    @MLostCookieKeyPolicy(withinNames = { MLostCookieNameEnum.MLSC_TEMP, MLostCookieNameEnum.MLSC_FOREVER})
	ACCOUNT_STATUS("status"),
    
    /**
     * 用户ID
     */
    @MLostCookieKeyPolicy(withinNames = { MLostCookieNameEnum.MLSC_TEMP, MLostCookieNameEnum.MLSC_FOREVER})
    ACCOUNT_ID("id"),
    
    /**
     * 是否是登录状态
     */
    @MLostCookieKeyPolicy(withinNames = { MLostCookieNameEnum.MLSC_TEMP })
    IS_SIGN("sign"),
	
	/**
	 * 下次是否自动登录
	 */
    @MLostCookieKeyPolicy(withinNames = { MLostCookieNameEnum.MLSC_FOREVER })
	AUTO_SIGN("auto_sign"),
	
	/**
	 * 上一次登录时间
	 */
	@MLostCookieKeyPolicy(withinNames = { MLostCookieNameEnum.MLSC_FOREVER })
	LAST_LOGIN_TIME("last_login_time");
    
    private String value;

    private MLostCookieKeyEnum(String value) {
        this.value = value;
    }

    public String getValue() {
        return this.value;
    }
    
    public static MLostCookieKeyEnum keyOf(String value) {
        if (StringUtils.isNotBlank(value)) {
            for (MLostCookieKeyEnum key : values()) {
                if (key.getValue().equals(value)) {
                    return key;
                }
            }
        }
        return null;
    }
}
